# buildit.sh
# script to build scsi disk image
# copyright (c) 2001 joseph cheek.  all rights reserved.
# released under gpl


# 
# 
# bin

[ -f bin/mol.gz ] || echo -e bin/mol.gz not found\!\!\\a


# 
# 
# sbin

[ -f sbin/fdisk.gz ] || echo -e sbin/fdisk.gz not found\!\!\\a


# 
# 
# modules

NEWMODDIR=lib/modules/`uname -r`/kernel/drivers  # no /; local
REALMODDIR=/lib/modules/`uname -r`/kernel/drivers  # note /; from root

rm -rf /mnt/scsi/lib # dangerous?
mkdir -p $NEWMODDIR

# ide
for a in block cdrom parport pnp scsi sound usb; do

  [ -d $NEWMODDIR/$a ] || mkdir -p $NEWMODDIR/$a

  case "$a" in

    block)
      COPY=loop*
      ;;

    cdrom)
      COPY=cdrom*
      ;;

    ide)
      COPY=ide-cd*
      ;;

    parport)
      COPY=*
      ;;

    pnp)
      COPY=isa-pnp*
      ;;

    scsi)
      COPY="* aic7xxx/*"
      ;;

    sound)
      COPY=sound*
      ;;

    usb)
      COPY="usbcore* usb-?hci* storage/*"
      ;;

  esac

set -f  # turn off glob expansion
  for b in $COPY; do
set +f  # turn it back on

    for c in `echo $REALMODDIR/$a/$b`; do
      gzip --best $c -c > $NEWMODDIR/$a/`basename $c`.gz
    done
  done

done

# final fixup

rm lib/modules/*/kernel/drivers/scsi/aic7xxx.gz
rm lib/modules/*/kernel/drivers/scsi/aacraid.gz
rm lib/modules/*/kernel/drivers/scsi/sym53c8xx_2.gz

